package com.hyc.yygh.controller;

import com.hyc.yygh.common.result.Result;
import com.hyc.yygh.model.hosp.Hospital;
import com.hyc.yygh.service.HospitalService;
import com.hyc.yygh.vo.hosp.HospitalQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    HospitalService hospitalService;

    @GetMapping("list/{page}/{limit}")
    public Result index(@PathVariable Integer page, @PathVariable Integer limit, HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> hospitals = hospitalService.selectPage(page, limit, hospitalQueryVo);
        List<Hospital> content = hospitals.getContent();
        long totalElements = hospitals.getTotalElements();
        return Result.ok(hospitals);
    }

    @GetMapping("updateStatus/{id}/{status}")
    public Result lock(@PathVariable("id") String id, @PathVariable("status") Integer status) {
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    @GetMapping("showHospDetail/{id}")
    public Result show(@PathVariable String id) {
        return Result.ok(hospitalService.getHospById(id));
    }

}
